/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 *
 *BaseCurrencyCheckItemInsController
 * 通用检查项实例
 *
 * 修改纪录
 * 2021-07-07 版本：1.0 chengengwei 创建。
 * @version 版本：1.0
 * @author 作者：chengengwei
 * 创建日期：2021-07-07
 */

package com.topscomm.base.controller;

import com.topscomm.base.controller.auto.BaseCurrencyCheckItemInsControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: chengengwei
 * @date: 2021-07-07
 * @description:通用检查项实例Controller
 * @modify:
 */
@RestController
@RequestMapping("base/currencyCheckItemIns")
public class BaseCurrencyCheckItemInsController extends BaseCurrencyCheckItemInsControllerAuto implements IBaseCurrencyCheckItemInsController {
	/**
	 * @author: chengengwei
	 * @date: 2021-07-07
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_name")) {
			String value = paraMap.get("qry_name").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and name like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_code")) {
			String value = paraMap.get("qry_code").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and code = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: chengengwei
	 * @date: 2021-07-07
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}

	/**
	 * @description:查询检查项实例列表
	 * @param paraMap
	 * @return
	 * @author: chengengwei
	 * @date: 2021-07-07
	 * @modify:
	 */
	@GetMapping(value = "/queryList")
	public ResponseResult<Object> queryList(@RequestParam(required = false) Map<String, Object> paraMap) {
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("dataList", this.service.queryList(paraMap));
		return ResponseResult.ok(resultMap);
	}

	/**
	 * @description: 暂存检查项实例
	 * @author: chengengwei
	 * @date: 2021-07-08
	 * @modify:
	 */
	@PutMapping(value = "/add")
	public ResponseResult<Object> add(@RequestBody(required = false) Map<String, Object> paraMap) {
		try {
			this.service.add(paraMap);
			return ResponseResult.ok("暂存成功");
		} catch (Exception e) {
			return handleControllerException(e);
		}
	}
}

